package moxl.xpath.parser.states.step;

import moxl.tokenizer.Token;
import moxl.tokenizer.TokenStream;
import moxl.xpath.parser.XPathParser;
import moxl.xpath.parser.XPathParserException;
import moxl.xpath.parser.states.XPathParserState;
import moxl.xpath.parser.types.NonTerminal;
import moxl.xpath.tokenizer.XPathTokenTypes;

public class XPathStepNodeTypeExpectingCloseParenthesisState extends XPathParserState
{
	private static XPathStepNodeTypeExpectingCloseParenthesisState instance = new XPathStepNodeTypeExpectingCloseParenthesisState();

	public static XPathStepNodeTypeExpectingCloseParenthesisState getInstance()
	{
		return instance;
	}

	@Override
    public void acceptCloseParenthesis(XPathParser ctx, TokenStream tstream, Token token, NonTerminal nonTerminal) throws XPathParserException
    {
		if (lookahead(tstream, 1) != null && lookahead(tstream, 1).getType().equals(XPathTokenTypes.OPEN_BRACKET))
		{
			ctx.changeState(XPathStepExpectingOpenPredicateState.getInstance());
		}
		else
		{
			ctx.changeState(XPathStepEndState.getInstance());
		}
    }
	
}
